﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GomeeSoft.src.classes.DiaryPages
{
    public partial class UCScheduleMonth : UserControl
    {
        public UCScheduleMonth()
        {
            InitializeComponent();
        }

        private void UCScheduleMonth_OnLoad(object sender, EventArgs e)
        {
            SetDate(DateTime.Now);
        }

        private void ucFramePanel1_Resize(object sender, EventArgs e)
        {
            ucSelectDay1.Left = Width - ucSelectDay1.Width - 5;
            ucSelectDay1.Top = Height - ucSelectDay1.Height - 7;
            lb_day.Width = ucSelectDay1.Left - lb_day.Left;
            lb_yearmonth.Width = lb_day.Width;
            lb_weekname.Width = lb_day.Width;
            lb_lunardate.Width = lb_day.Width;
        }

        private void ucSelectDay1_OnDateSelected(object sender, EventArgs e, DateTime d)
        {
            SetDate(d);
            DateSelected(EventArgs.Empty, d);
        }

        private void SetDate(DateTime d)
        {
            ucSelectDay1.SelectedDate = d;
            lb_day.Text = d.Day.ToString();
            lb_yearmonth.Text = d.Year.ToString() + "/" + d.Month.ToString();
            lb_weekname.Text = d.DayOfWeek.ToString();
            Calendar.LunarDate ld = Calendar.ToKoreanLunarDate(d);
            lb_lunardate.Text = ld.lunYear.ToString() + "/" +
                                ld.lunMonth.ToString() + "/" +
                                ld.lunDay.ToString() +
                                (ld.isLunYun ? "(윤)" : "");
        }

        public delegate void EventHandler(object sender, EventArgs e, DateTime d);
        public event EventHandler OnDateSelected;
        protected virtual void DateSelected(EventArgs e, DateTime d)
        {
            OnDateSelected(this, e, d);
        }
    }
}
